/**
 * @Description 添加数据到数组中，如数据重复，删除之前重复数据，将重复数据增加到数组的末尾
 * @param { Array } list 需要对比的数组
 * @param { Object,String } data 需要对比的数据,如有name的情况下：是Object || 则是String
 * @param { String } name 需要对比数据的变量名
 */
export const duplicateRemoval = (list = [], data, name) => {
    // console.log('list',list, data, name)
    if (!list || !list.length) list.push(data)
    else {
        let foundIndex = 0
        if (!name) foundIndex = list.findIndex(item => item === data);
        else foundIndex = list.findIndex(item => item[name] === data[name]);
        if (foundIndex == -1) list.push(data)
        // else {
        //     list.shift(foundIndex, 1)
        //     list.push(data)
        // }
    }
    // console.log('list', list)
    return list
}